﻿Shader "Unlit/WaterBlender"
{
    Properties
    {
        _MainTex("Main Texture", 2D) = "white" {}
        _Dim("Dim", float) = 0
    }
    SubShader
    {
        Tags{"RenderType" = "Opaque" "Queue" = "Geometry"}
        Pass
        {
            Tags{"LightMode" = "ForwardBase"}
            CGPROGRAM

            #pragma vertex vert
            #pragma fragment frag 

            #include "Lighting.cginc"
            #include "AutoLight.cginc"
            
            float _Dim;
            sampler2D _MainTex;
            float4 _MainTex_ST;

            struct v2f{
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
            };

            v2f vert(appdata_base v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {
                fixed4 color = tex2D(_MainTex, i.uv);
                //color = smoothstep()
                // color.r /= 2.0;
                float outcolor = smoothstep(0.28, 0.29 + _Dim, color.r);
                if(outcolor < 0.01)
                    return fixed4(0.1, 0.3, 0.4, 1);
                else
                    return fixed4(outcolor, outcolor, outcolor, 1);
                
                // color = fixed4(0, color.x/2.0, color.x, 1);

                // color = floor(color / 0.1)*0.5;
                

                //return fixed4(color.xyz, 1);
            }

            ENDCG
        }
    }
    FallBack "Specular"
}
